﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BackupLib.Targets
{
    using System.IO;
    using System.Reflection;

    internal class TargetFactory
    {
        internal static IBackupTarget GetBackupTarget(string targetRoot)
        {
            Uri target= new Uri(targetRoot);

            switch (target.Scheme)
            {
                case "ftp":
                    return new FTP();
                case "file": 
                    DriveInfo di = new DriveInfo(targetRoot);

                    if (di.DriveFormat.Equals("NTFS", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return new NTFS();
                    }
                    else if (di.DriveFormat.StartsWith("ext", StringComparison.InvariantCultureIgnoreCase))
                    {
                        return new Ext2();
                    }
                    return new Filesystem();
                default:
                    throw new NotImplementedException(target.Scheme);
            }
        }
    }
}
